#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

template <typename T>
void print_all(const T& S)
{
        for (const auto& x : S)
                cout << x << ' ';
        cout << endl;
}

int main()
{
        const int SIZE = 20;
        int n;
        vector<int> v;
        v.reserve(SIZE);
        cin >> n;
        // cout << n << endl;
        while (n != 0)
        {
                v.push_back(n % 10);
                n /= 10;
        }
        // print_all(v);
        // exit(1);
        swap(v.front(), v.back());
        // cout << v.back() << ' ' << v.front() << endl;
        // print_all(v);
        // exit(1);
        int ret = 0;
        size_t i = v.size() - 1;
        for (auto iter = v.rbegin(); iter != v.rend(); iter++)
        {
                ret += *iter * pow(10, i);
                i--;
        }
        cout << ret << endl;
        return 0;
}